tcp: tcp_fragment() should apply sane memory limits
authorEric Dumazet <edumazet@google.com>
Mon, 17 Jun 2019 17:03:52 +0000 (10:03 -0700)
committerBen Hutchings <ben@decadent.org.uk>
Wed, 19 Jun 2019 22:16:58 +0000 (23:16 +0100)
commitc20c035ccdd3169802a7eeeb3e13a95471e0b1ba
tree158be277c7af0e3938463af2983b0a22beb16c73
parent7d79c8c8c42378e87e88ec15738b27d0aff68b87
tcp: tcp_fragment() should apply sane memory limits

Jonathan Looney reported that a malicious peer can force a sender
to fragment its retransmit queue into tiny skbs, inflating memory
usage and/or overflow 32bit counters.

TCP allows an application to queue up to sk_sndbuf bytes,
so we need to give some allowance for non malicious splitting
of retransmit queue.

A new SNMP counter is added to monitor how many times TCP
did not allow to split an skb if the allowance was exceeded.

Note that this counter might increase in the case applications
use SO_SNDBUF socket option to lower sk_sndbuf.

CVE-2019-11478 : tcp_fragment, prevent fragmenting a packet when the
socket is already using more than half the allowed space

Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: Jonathan Looney <jtl@netflix.com>
Acked-by: Neal Cardwell <ncardwell@google.com>
Acked-by: Yuchung Cheng <ycheng@google.com>
Reviewed-by: Tyler Hicks <tyhicks@canonical.com>
Cc: Bruce Curtis <brucec@netflix.com>
Cc: Jonathan Lemon <jonathan.lemon@gmail.com>
Acked-by: Jonathan Lemon <jonathan.lemon@gmail.com>
Gbp-Pq: Topic bugfix/all
Gbp-Pq: Name tcp-tcp_fragment-should-apply-sane-memory-limits.patch
include/uapi/linux/snmp.h
net/ipv4/proc.c
net/ipv4/tcp_output.c